﻿package mortal.game.view.playerSystem.view
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import com.gengine.debug.*;
    import com.mui.controls.*;
    import com.mui.manager.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.resource.configBase.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class PlayerAttributeInfoPart extends GSprite
    {
        private var _attrNameArray:Array;
        private var _attribute:Vector.<String>;
        private var _valArr:Array;
        private var _txtVec:Vector.<GTextFiled>;
        private var sFightAttribute:SFightAttribute;
        private var sRole:SRole;
        private var _attackVal:BitmapNumberText;
        private var _physDefenseVal:BitmapNumberText;
        private var _magicDefenseVal:BitmapNumberText;
        private var _penetrationVal:BitmapNumberText;
        private var _joukVal:BitmapNumberText;
        private var _hitVal:BitmapNumberText;
        private var _critVal:BitmapNumberText;
        private var _toughnessVal:BitmapNumberText;
        private var _blockVal:BitmapNumberText;
        private var _expertiseVal:BitmapNumberText;
        private var _comBat:BitmapNumberText;
        private var _playerTarget:PlayerTargetPanel;
        private var _shengmingBar:BaseProgressBar;
        private var _mofaBar:BaseProgressBar;
        private var _jinyanBar:BaseProgressBar;

        public function PlayerAttributeInfoPart()
        {
            this._attrNameArray = [Language.getString(30124), Language.getString(30126), Language.getString(30125), Language.getString(30127), Language.getString(30128), Language.getString(30129), Language.getString(30130), Language.getString(30131), Language.getString(30132), Language.getString(30133)];
            this._attribute = new Vector.<String>;
            this.sRole = Cache.instance.role.roleInfo;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_2:GTextFormat = null;
            super.createDisposedChildrenImpl();
            this._attribute.push("attack", "life", "physDefense", "magicDefense", "penetration", "jouk", "hit", "crit", "toughness", "block", "expertise");
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.playerModule_attrBg, 0, 0, this));
            var _loc_1:* = UICompomentPool.getUICompoment(ToolTipSprite);
            _loc_1.toolTipData = Language.getString(35016);
            this.addChild(_loc_1);
            this.pushUIToDisposeVec(_loc_1);
            _loc_2 = GlobalStyle.textFormatAnHuan;
            _loc_2.size = 12;
            this._comBat = UIFactory.bitmapNumberText(128, 40, "GuildCopyNum.png", 24, 32, -6, this, 9, BitmapNumberText.Mid);
            this._comBat.toolTipData = Language.getString(35015);
            _loc_2 = GlobalStyle.textFormatPutong;
            _loc_2.size = 10;
            this._shengmingBar = UICompomentPool.getUICompoment(BaseProgressBar);
            this._shengmingBar.setBg(ImagesConst.PetLifeBg, true, 150, 12);
            this._shengmingBar.setProgress(ImagesConst.PetLife, true, 1, 1, 148, 10);
            this._shengmingBar.setLabel(BaseProgressBar.ProgressBarTextNumber, 0, -4, 150, 8, _loc_2, "{0}");
            this._shengmingBar.x = 85;
            this._shengmingBar.y = 249;
            this.addChild(this._shengmingBar);
            this._mofaBar = UICompomentPool.getUICompoment(BaseProgressBar);
            this._mofaBar.setBg(ImagesConst.PetLifeBg, true, 150, 12);
            this._mofaBar.setProgress(ImagesConst.PetLifespan, true, 1, 1, 148, 10);
            this._mofaBar.setLabel(BaseProgressBar.ProgressBarTextNumber, 0, -4, 150, 8, _loc_2);
            this._mofaBar.x = 85;
            this._mofaBar.y = 272;
            this.addChild(this._mofaBar);
            this._jinyanBar = UICompomentPool.getUICompoment(BaseProgressBar);
            this._jinyanBar.setBg(ImagesConst.PetLifeBg, true, 150, 12);
            this._jinyanBar.setProgress(ImagesConst.PetExp, true, 1, 1, 148, 10);
            this._jinyanBar.setLabel(BaseProgressBar.ProgressBarTextPercent, 0, -4, 150, 8, _loc_2);
            this._jinyanBar.mouseChildren = false;
            this._jinyanBar.mouseEnabled = true;
            this._jinyanBar.buttonMode = true;
            this._jinyanBar.x = 85;
            this._jinyanBar.y = 295;
            this.addChild(this._jinyanBar);
            this._valArr = [];
            this._attackVal = this.createAttrVal();
            this._valArr.push(this._attackVal);
            this._physDefenseVal = this.createAttrVal();
            this._valArr.push(this._physDefenseVal);
            this._magicDefenseVal = this.createAttrVal();
            this._valArr.push(this._magicDefenseVal);
            this._penetrationVal = this.createAttrVal();
            this._valArr.push(this._penetrationVal);
            this._joukVal = this.createAttrVal();
            this._valArr.push(this._joukVal);
            this._hitVal = this.createAttrVal();
            this._valArr.push(this._hitVal);
            this._critVal = this.createAttrVal();
            this._valArr.push(this._critVal);
            this._toughnessVal = this.createAttrVal();
            this._valArr.push(this._toughnessVal);
            this._blockVal = this.createAttrVal();
            this._valArr.push(this._blockVal);
            this._expertiseVal = this.createAttrVal();
            this._valArr.push(this._expertiseVal);
            _loc_2 = GlobalStyle.textFormatAnHuan;
            _loc_2.size = 12;
            this._playerTarget = UICompomentPool.getUICompoment(PlayerTargetPanel);
            this._playerTarget.move(46, 162);
            this.addChild(this._playerTarget);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            var _loc_2:BitmapNumberText = null;
            for each (_loc_2 in this._valArr)
            {
                
                _loc_2.dispose(param1);
            }
            this._valArr.length = 0;
            this._attribute.length = 0;
            this._shengmingBar.dispose(param1);
            this._mofaBar.dispose(param1);
            this._jinyanBar.dispose(param1);
            this._comBat.dispose(param1);
            this._shengmingBar = null;
            this._mofaBar = null;
            this._jinyanBar = null;
            this._comBat = null;
            this._attackVal = null;
            this._physDefenseVal = null;
            this._magicDefenseVal = null;
            this._penetrationVal = null;
            this._joukVal = null;
            this._hitVal = null;
            this._critVal = null;
            this._toughnessVal = null;
            this._blockVal = null;
            this._expertiseVal = null;
            this._playerTarget.dispose(param1);
            this._playerTarget = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function createAttrVal() : BitmapNumberText
        {
            var _loc_1:* = this._valArr.length;
            var _loc_2:int = 86;
            var _loc_3:int = 318.5;
            var _loc_4:Number = 23;
            var _loc_5:* = GlobalStyle.textFormatBai;
            _loc_5.size = 12;
            _loc_5.align = TextFormatAlign.LEFT;
            var _loc_6:* = UIFactory.bitmapNumberText(_loc_2, _loc_3 + _loc_4 * _loc_1, "RoleInfoNum.png", 8, 10, -1, this, 14);
            _loc_6.toolTipData = Language.getString(35005 + _loc_1);
            return _loc_6;
        }// end function

        private function createAttrTxt() : void
        {
            var _loc_6:int = 0;
            var _loc_7:GTextFiled = null;
            var _loc_1:int = 9;
            var _loc_2:int = 5;
            var _loc_3:int = 178;
            var _loc_4:int = 23;
            var _loc_5:* = GlobalStyle.textFormatAnHuan;
            _loc_5.size = 12;
            while (_loc_6 < _loc_1)
            {
                
                _loc_7 = UIFactory.gTextField(this._attrNameArray[(_loc_6 + 1)], _loc_2, _loc_3 + _loc_4 * (_loc_6 + 1), 180, 25, this, _loc_5, true);
                _loc_7.toolTipData = Language.getString(35006 + _loc_6);
                pushUIToDisposeVec(_loc_7);
                _loc_6++;
            }
            return;
        }// end function

        public function updateAllInfo(param1:SFightAttribute) : void
        {
            this.sFightAttribute = param1;
            this.updateAttr();
            this.updateComBat();
            this.updateLife();
            this.updateMana();
            this.updateExp(this.sRole.experience);
            return;
        }// end function

        public function updateLife() : void
        {
            this._shengmingBar.setValue(Cache.instance.role.entityInfo.life, Cache.instance.role.entityInfo.maxLife);
            return;
        }// end function

        public function updateMana() : void
        {
            this._mofaBar.setValue(Cache.instance.role.entityInfo.mana, Cache.instance.role.entityInfo.maxMana);
            return;
        }// end function

        public function updateExp(param1:int = 0) : void
        {
            var _loc_2:* = ConfigCenter.getConfigs(ConfigConst.expLevel, "level", this.sRole.level, true) as TExperience;
            this._jinyanBar.setValue(param1, _loc_2.upgradeNeedExperience);
            this._jinyanBar.toolTipData = param1 + "/" + _loc_2.upgradeNeedExperience;
            return;
        }// end function

        public function updateLevel() : void
        {
            var _loc_1:* = ConfigCenter.getConfigs(ConfigConst.expLevel, "level", this.sRole.level, true) as TExperience;
            this._jinyanBar.totalValue = _loc_1.upgradeNeedExperience;
            return;
        }// end function

        public function updateAttr() : void
        {
            Log.debug("战斗属性更新");
            this._attackVal.text = this.sFightAttribute.attack.toString();
            this._physDefenseVal.text = this.sFightAttribute.physDefense.toString();
            this._magicDefenseVal.text = this.sFightAttribute.magicDefense.toString();
            this._penetrationVal.text = this.sFightAttribute.penetration.toString();
            this._joukVal.text = this.sFightAttribute.jouk.toString();
            this._hitVal.text = this.sFightAttribute.hit.toString();
            this._critVal.text = this.sFightAttribute.crit.toString();
            this._toughnessVal.text = this.sFightAttribute.toughness.toString();
            this._blockVal.text = this.sFightAttribute.block.toString();
            this._expertiseVal.text = this.sFightAttribute.expertise.toString();
            return;
        }// end function

        public function updateComBat() : void
        {
            this._comBat.text = Cache.instance.role.entityInfo.combat.toString();
            return;
        }// end function

    }
}
